#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: common_sync_sink_node.py 
@version:
@time: 2022/01/06 
"""
from TapClientCore.T04_logic.Dag01.node.node_base import NodeBase, TapdataNoThisDataSource


class CommonSyncSinkNode(NodeBase):

    def __init__(self, name, data):
        self.id = self.newId
        if isinstance(name, dict):
            self.name = name['name']
        else:
            self.name = name
        self.type = data['type']
        self.table = data['table']
        self.tableId = None
        self.attribute = self.sole()

    def sole(self):
        response = self.TM.get_connections_by_name(self.name)
        this_node = {
            'id': self.id,
            'name': self.name,
            "inputLanes": [],
            "outputLanes": [],
            "connectionId": response["data"][0]["id"],
            "databaseType": response["data"][0]["database_type"],
            "tableName": self.table,
            "joinTables": [],
            "type": self.type

        }
        return this_node
